{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "## 安装 python-graphviz 画图工具\n",
    "## conda install python-graphviz"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn import tree\n",
    "## 导入数据集（红酒数据）\n",
    "from sklearn.datasets import load_wine\n",
    "## 训练集测试分类\n",
    "from sklearn.model_selection import train_test_split"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "wine = load_wine()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1.423e+01, 1.710e+00, 2.430e+00, ..., 1.040e+00, 3.920e+00,\n",
       "        1.065e+03],\n",
       "       [1.320e+01, 1.780e+00, 2.140e+00, ..., 1.050e+00, 3.400e+00,\n",
       "        1.050e+03],\n",
       "       [1.316e+01, 2.360e+00, 2.670e+00, ..., 1.030e+00, 3.170e+00,\n",
       "        1.185e+03],\n",
       "       ...,\n",
       "       [1.327e+01, 4.280e+00, 2.260e+00, ..., 5.900e-01, 1.560e+00,\n",
       "        8.350e+02],\n",
       "       [1.317e+01, 2.590e+00, 2.370e+00, ..., 6.000e-01, 1.620e+00,\n",
       "        8.400e+02],\n",
       "       [1.413e+01, 4.100e+00, 2.740e+00, ..., 6.100e-01, 1.600e+00,\n",
       "        5.600e+02]])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wine.data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(178, 13)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wine.data.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,\n",
       "       2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n",
       "       2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n",
       "       2, 2])"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wine.target"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>10</th>\n",
       "      <th>11</th>\n",
       "      <th>12</th>\n",
       "      <th>0</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>14.23</td>\n",
       "      <td>1.71</td>\n",
       "      <td>2.43</td>\n",
       "      <td>15.6</td>\n",
       "      <td>127.0</td>\n",
       "      <td>2.80</td>\n",
       "      <td>3.06</td>\n",
       "      <td>0.28</td>\n",
       "      <td>2.29</td>\n",
       "      <td>5.64</td>\n",
       "      <td>1.04</td>\n",
       "      <td>3.92</td>\n",
       "      <td>1065.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>13.20</td>\n",
       "      <td>1.78</td>\n",
       "      <td>2.14</td>\n",
       "      <td>11.2</td>\n",
       "      <td>100.0</td>\n",
       "      <td>2.65</td>\n",
       "      <td>2.76</td>\n",
       "      <td>0.26</td>\n",
       "      <td>1.28</td>\n",
       "      <td>4.38</td>\n",
       "      <td>1.05</td>\n",
       "      <td>3.40</td>\n",
       "      <td>1050.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>13.16</td>\n",
       "      <td>2.36</td>\n",
       "      <td>2.67</td>\n",
       "      <td>18.6</td>\n",
       "      <td>101.0</td>\n",
       "      <td>2.80</td>\n",
       "      <td>3.24</td>\n",
       "      <td>0.30</td>\n",
       "      <td>2.81</td>\n",
       "      <td>5.68</td>\n",
       "      <td>1.03</td>\n",
       "      <td>3.17</td>\n",
       "      <td>1185.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>14.37</td>\n",
       "      <td>1.95</td>\n",
       "      <td>2.50</td>\n",
       "      <td>16.8</td>\n",
       "      <td>113.0</td>\n",
       "      <td>3.85</td>\n",
       "      <td>3.49</td>\n",
       "      <td>0.24</td>\n",
       "      <td>2.18</td>\n",
       "      <td>7.80</td>\n",
       "      <td>0.86</td>\n",
       "      <td>3.45</td>\n",
       "      <td>1480.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>13.24</td>\n",
       "      <td>2.59</td>\n",
       "      <td>2.87</td>\n",
       "      <td>21.0</td>\n",
       "      <td>118.0</td>\n",
       "      <td>2.80</td>\n",
       "      <td>2.69</td>\n",
       "      <td>0.39</td>\n",
       "      <td>1.82</td>\n",
       "      <td>4.32</td>\n",
       "      <td>1.04</td>\n",
       "      <td>2.93</td>\n",
       "      <td>735.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>173</td>\n",
       "      <td>13.71</td>\n",
       "      <td>5.65</td>\n",
       "      <td>2.45</td>\n",
       "      <td>20.5</td>\n",
       "      <td>95.0</td>\n",
       "      <td>1.68</td>\n",
       "      <td>0.61</td>\n",
       "      <td>0.52</td>\n",
       "      <td>1.06</td>\n",
       "      <td>7.70</td>\n",
       "      <td>0.64</td>\n",
       "      <td>1.74</td>\n",
       "      <td>740.0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>174</td>\n",
       "      <td>13.40</td>\n",
       "      <td>3.91</td>\n",
       "      <td>2.48</td>\n",
       "      <td>23.0</td>\n",
       "      <td>102.0</td>\n",
       "      <td>1.80</td>\n",
       "      <td>0.75</td>\n",
       "      <td>0.43</td>\n",
       "      <td>1.41</td>\n",
       "      <td>7.30</td>\n",
       "      <td>0.70</td>\n",
       "      <td>1.56</td>\n",
       "      <td>750.0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>175</td>\n",
       "      <td>13.27</td>\n",
       "      <td>4.28</td>\n",
       "      <td>2.26</td>\n",
       "      <td>20.0</td>\n",
       "      <td>120.0</td>\n",
       "      <td>1.59</td>\n",
       "      <td>0.69</td>\n",
       "      <td>0.43</td>\n",
       "      <td>1.35</td>\n",
       "      <td>10.20</td>\n",
       "      <td>0.59</td>\n",
       "      <td>1.56</td>\n",
       "      <td>835.0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>176</td>\n",
       "      <td>13.17</td>\n",
       "      <td>2.59</td>\n",
       "      <td>2.37</td>\n",
       "      <td>20.0</td>\n",
       "      <td>120.0</td>\n",
       "      <td>1.65</td>\n",
       "      <td>0.68</td>\n",
       "      <td>0.53</td>\n",
       "      <td>1.46</td>\n",
       "      <td>9.30</td>\n",
       "      <td>0.60</td>\n",
       "      <td>1.62</td>\n",
       "      <td>840.0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>177</td>\n",
       "      <td>14.13</td>\n",
       "      <td>4.10</td>\n",
       "      <td>2.74</td>\n",
       "      <td>24.5</td>\n",
       "      <td>96.0</td>\n",
       "      <td>2.05</td>\n",
       "      <td>0.76</td>\n",
       "      <td>0.56</td>\n",
       "      <td>1.35</td>\n",
       "      <td>9.20</td>\n",
       "      <td>0.61</td>\n",
       "      <td>1.60</td>\n",
       "      <td>560.0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>178 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        0     1     2     3      4     5     6     7     8      9     10  \\\n",
       "0    14.23  1.71  2.43  15.6  127.0  2.80  3.06  0.28  2.29   5.64  1.04   \n",
       "1    13.20  1.78  2.14  11.2  100.0  2.65  2.76  0.26  1.28   4.38  1.05   \n",
       "2    13.16  2.36  2.67  18.6  101.0  2.80  3.24  0.30  2.81   5.68  1.03   \n",
       "3    14.37  1.95  2.50  16.8  113.0  3.85  3.49  0.24  2.18   7.80  0.86   \n",
       "4    13.24  2.59  2.87  21.0  118.0  2.80  2.69  0.39  1.82   4.32  1.04   \n",
       "..     ...   ...   ...   ...    ...   ...   ...   ...   ...    ...   ...   \n",
       "173  13.71  5.65  2.45  20.5   95.0  1.68  0.61  0.52  1.06   7.70  0.64   \n",
       "174  13.40  3.91  2.48  23.0  102.0  1.80  0.75  0.43  1.41   7.30  0.70   \n",
       "175  13.27  4.28  2.26  20.0  120.0  1.59  0.69  0.43  1.35  10.20  0.59   \n",
       "176  13.17  2.59  2.37  20.0  120.0  1.65  0.68  0.53  1.46   9.30  0.60   \n",
       "177  14.13  4.10  2.74  24.5   96.0  2.05  0.76  0.56  1.35   9.20  0.61   \n",
       "\n",
       "       11      12  0   \n",
       "0    3.92  1065.0   0  \n",
       "1    3.40  1050.0   0  \n",
       "2    3.17  1185.0   0  \n",
       "3    3.45  1480.0   0  \n",
       "4    2.93   735.0   0  \n",
       "..    ...     ...  ..  \n",
       "173  1.74   740.0   2  \n",
       "174  1.56   750.0   2  \n",
       "175  1.56   835.0   2  \n",
       "176  1.62   840.0   2  \n",
       "177  1.60   560.0   2  \n",
       "\n",
       "[178 rows x 14 columns]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "pd.concat([pd.DataFrame(wine.data), pd.DataFrame(wine.target)], axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['alcohol',\n",
       " 'malic_acid',\n",
       " 'ash',\n",
       " 'alcalinity_of_ash',\n",
       " 'magnesium',\n",
       " 'total_phenols',\n",
       " 'flavanoids',\n",
       " 'nonflavanoid_phenols',\n",
       " 'proanthocyanins',\n",
       " 'color_intensity',\n",
       " 'hue',\n",
       " 'od280/od315_of_diluted_wines',\n",
       " 'proline']"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "## 特征的名字\n",
    "wine.feature_names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['class_0', 'class_1', 'class_2'], dtype='<U7')"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wine.target_names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "## 区分测试集和训练集\n",
    "## test_size=0.3 : 30%作为测试集 70%作为训练集\n",
    "Xtrain, Xtest, Ytrain, Ytest = train_test_split(wine.data, wine.target, test_size=0.3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[1.277e+01 3.430e+00 1.980e+00 ... 7.000e-01 2.120e+00 3.720e+02]\n",
      " [1.184e+01 8.900e-01 2.580e+00 ... 7.900e-01 3.080e+00 5.200e+02]\n",
      " [1.282e+01 3.370e+00 2.300e+00 ... 7.200e-01 1.750e+00 6.850e+02]\n",
      " ...\n",
      " [1.330e+01 1.720e+00 2.140e+00 ... 1.020e+00 2.770e+00 1.285e+03]\n",
      " [1.162e+01 1.990e+00 2.280e+00 ... 1.160e+00 2.960e+00 3.450e+02]\n",
      " [1.421e+01 4.040e+00 2.440e+00 ... 8.700e-01 3.330e+00 1.080e+03]]\n",
      "(124, 13)\n"
     ]
    }
   ],
   "source": [
    "print(Xtrain)\n",
    "print(Xtrain.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(54, 13)"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Xtest.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 1, 2, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 2, 0, 1, 2, 0, 1, 0, 1, 1,\n",
       "       1, 0, 2, 0, 1, 0, 1, 0, 2, 1, 2, 1, 1, 0, 2, 2, 2, 0, 1, 0, 1, 1,\n",
       "       1, 1, 0, 0, 0, 1, 0, 2, 1, 2, 0, 0, 0, 2, 2, 0, 1, 1, 0, 1, 1, 2,\n",
       "       0, 0, 1, 2, 1, 2, 1, 0, 1, 1, 1, 2, 1, 0, 1, 2, 1, 0, 0, 2, 1, 1,\n",
       "       1, 1, 0, 2, 0, 0, 0, 0, 0, 1, 1, 2, 2, 1, 2, 2, 0, 1, 0, 0, 1, 1,\n",
       "       2, 2, 0, 1, 0, 2, 2, 2, 1, 0, 2, 0, 1, 0])"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Ytrain"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "## 建模\n",
    "## 基尼系数\n",
    "clf = tree.DecisionTreeClassifier(criterion=\"entropy\")\n",
    "# 训练的模型接口\n",
    "clf = clf.fit(Xtrain, Ytrain)\n",
    "# 使用测试集打分\n",
    "# 返回预测的准确度 accuracy\n",
    "score = clf.score(Xtest, Ytest)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.8703703703703703"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "score"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\r\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n",
       "<!-- Generated by graphviz version 2.38.0 (20140413.2041)\r\n",
       " -->\r\n",
       "<!-- Title: Tree Pages: 1 -->\r\n",
       "<svg width=\"861pt\" height=\"671pt\"\r\n",
       " viewBox=\"0.00 0.00 861.00 671.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 667)\">\r\n",
       "<title>Tree</title>\r\n",
       "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-667 857,-667 857,4 -4,4\"/>\r\n",
       "<!-- 0 -->\r\n",
       "<g id=\"node1\" class=\"node\"><title>0</title>\r\n",
       "<path fill=\"#f0fdf6\" stroke=\"black\" d=\"M520,-663C520,-663 407,-663 407,-663 401,-663 395,-657 395,-651 395,-651 395,-592 395,-592 395,-586 401,-580 407,-580 407,-580 520,-580 520,-580 526,-580 532,-586 532,-592 532,-592 532,-651 532,-651 532,-657 526,-663 520,-663\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"463.5\" y=\"-647.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">脯氨酸 &lt;= 760.0</text>\r\n",
       "<text text-anchor=\"middle\" x=\"463.5\" y=\"-632.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 1.554</text>\r\n",
       "<text text-anchor=\"middle\" x=\"463.5\" y=\"-617.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 124</text>\r\n",
       "<text text-anchor=\"middle\" x=\"463.5\" y=\"-602.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [44, 50, 30]</text>\r\n",
       "<text text-anchor=\"middle\" x=\"463.5\" y=\"-587.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪梨</text>\r\n",
       "</g>\r\n",
       "<!-- 1 -->\r\n",
       "<g id=\"node2\" class=\"node\"><title>1</title>\r\n",
       "<path fill=\"#a8f4c8\" stroke=\"black\" d=\"M420,-544C420,-544 315,-544 315,-544 309,-544 303,-538 303,-532 303,-532 303,-473 303,-473 303,-467 309,-461 315,-461 315,-461 420,-461 420,-461 426,-461 432,-467 432,-473 432,-473 432,-532 432,-532 432,-538 426,-544 420,-544\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"367.5\" y=\"-528.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">类黄酮 &lt;= 1.235</text>\r\n",
       "<text text-anchor=\"middle\" x=\"367.5\" y=\"-513.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 1.086</text>\r\n",
       "<text text-anchor=\"middle\" x=\"367.5\" y=\"-498.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 76</text>\r\n",
       "<text text-anchor=\"middle\" x=\"367.5\" y=\"-483.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [2, 48, 26]</text>\r\n",
       "<text text-anchor=\"middle\" x=\"367.5\" y=\"-468.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪梨</text>\r\n",
       "</g>\r\n",
       "<!-- 0&#45;&gt;1 -->\r\n",
       "<g id=\"edge1\" class=\"edge\"><title>0&#45;&gt;1</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M430.193,-579.907C422.747,-570.832 414.779,-561.121 407.106,-551.769\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"409.797,-549.531 400.748,-544.021 404.385,-553.972 409.797,-549.531\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"398.295\" y=\"-565.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">True</text>\r\n",
       "</g>\r\n",
       "<!-- 12 -->\r\n",
       "<g id=\"node13\" class=\"node\"><title>12</title>\r\n",
       "<path fill=\"#e99254\" stroke=\"black\" d=\"M658.5,-544C658.5,-544 462.5,-544 462.5,-544 456.5,-544 450.5,-538 450.5,-532 450.5,-532 450.5,-473 450.5,-473 450.5,-467 456.5,-461 462.5,-461 462.5,-461 658.5,-461 658.5,-461 664.5,-461 670.5,-467 670.5,-473 670.5,-473 670.5,-532 670.5,-532 670.5,-538 664.5,-544 658.5,-544\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"560.5\" y=\"-528.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">od280/od315稀释葡萄酒 &lt;= 2.255</text>\r\n",
       "<text text-anchor=\"middle\" x=\"560.5\" y=\"-513.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.658</text>\r\n",
       "<text text-anchor=\"middle\" x=\"560.5\" y=\"-498.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 48</text>\r\n",
       "<text text-anchor=\"middle\" x=\"560.5\" y=\"-483.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [42, 2, 4]</text>\r\n",
       "<text text-anchor=\"middle\" x=\"560.5\" y=\"-468.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 琴酒</text>\r\n",
       "</g>\r\n",
       "<!-- 0&#45;&gt;12 -->\r\n",
       "<g id=\"edge12\" class=\"edge\"><title>0&#45;&gt;12</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M497.154,-579.907C504.677,-570.832 512.729,-561.121 520.482,-551.769\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"523.218,-553.953 526.906,-544.021 517.829,-549.485 523.218,-553.953\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"529.232\" y=\"-565.212\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">False</text>\r\n",
       "</g>\r\n",
       "<!-- 2 -->\r\n",
       "<g id=\"node3\" class=\"node\"><title>2</title>\r\n",
       "<path fill=\"#9152e8\" stroke=\"black\" d=\"M229,-425C229,-425 132,-425 132,-425 126,-425 120,-419 120,-413 120,-413 120,-354 120,-354 120,-348 126,-342 132,-342 132,-342 229,-342 229,-342 235,-342 241,-348 241,-354 241,-354 241,-413 241,-413 241,-419 235,-425 229,-425\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"180.5\" y=\"-409.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">色调 &lt;= 0.92</text>\r\n",
       "<text text-anchor=\"middle\" x=\"180.5\" y=\"-394.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.503</text>\r\n",
       "<text text-anchor=\"middle\" x=\"180.5\" y=\"-379.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 27</text>\r\n",
       "<text text-anchor=\"middle\" x=\"180.5\" y=\"-364.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 3, 24]</text>\r\n",
       "<text text-anchor=\"middle\" x=\"180.5\" y=\"-349.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 贝尔摩德</text>\r\n",
       "</g>\r\n",
       "<!-- 1&#45;&gt;2 -->\r\n",
       "<g id=\"edge2\" class=\"edge\"><title>1&#45;&gt;2</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M302.883,-461.071C285.803,-450.384 267.296,-438.805 249.97,-427.965\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"251.365,-424.709 241.031,-422.372 247.652,-430.644 251.365,-424.709\"/>\r\n",
       "</g>\r\n",
       "<!-- 5 -->\r\n",
       "<g id=\"node6\" class=\"node\"><title>5</title>\r\n",
       "<path fill=\"#4ae78c\" stroke=\"black\" d=\"M467.5,-425C467.5,-425 271.5,-425 271.5,-425 265.5,-425 259.5,-419 259.5,-413 259.5,-413 259.5,-354 259.5,-354 259.5,-348 265.5,-342 271.5,-342 271.5,-342 467.5,-342 467.5,-342 473.5,-342 479.5,-348 479.5,-354 479.5,-354 479.5,-413 479.5,-413 479.5,-419 473.5,-425 467.5,-425\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"369.5\" y=\"-409.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">od280/od315稀释葡萄酒 &lt;= 1.445</text>\r\n",
       "<text text-anchor=\"middle\" x=\"369.5\" y=\"-394.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.49</text>\r\n",
       "<text text-anchor=\"middle\" x=\"369.5\" y=\"-379.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 49</text>\r\n",
       "<text text-anchor=\"middle\" x=\"369.5\" y=\"-364.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [2, 45, 2]</text>\r\n",
       "<text text-anchor=\"middle\" x=\"369.5\" y=\"-349.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪梨</text>\r\n",
       "</g>\r\n",
       "<!-- 1&#45;&gt;5 -->\r\n",
       "<g id=\"edge5\" class=\"edge\"><title>1&#45;&gt;5</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M368.194,-460.907C368.337,-452.558 368.489,-443.671 368.636,-435.02\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"372.136,-435.079 368.807,-425.021 365.137,-434.959 372.136,-435.079\"/>\r\n",
       "</g>\r\n",
       "<!-- 3 -->\r\n",
       "<g id=\"node4\" class=\"node\"><title>3</title>\r\n",
       "<path fill=\"#8139e5\" stroke=\"black\" d=\"M109,-298.5C109,-298.5 12,-298.5 12,-298.5 6,-298.5 0,-292.5 0,-286.5 0,-286.5 0,-242.5 0,-242.5 0,-236.5 6,-230.5 12,-230.5 12,-230.5 109,-230.5 109,-230.5 115,-230.5 121,-236.5 121,-242.5 121,-242.5 121,-286.5 121,-286.5 121,-292.5 115,-298.5 109,-298.5\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"60.5\" y=\"-283.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\r\n",
       "<text text-anchor=\"middle\" x=\"60.5\" y=\"-268.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 24</text>\r\n",
       "<text text-anchor=\"middle\" x=\"60.5\" y=\"-253.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 24]</text>\r\n",
       "<text text-anchor=\"middle\" x=\"60.5\" y=\"-238.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 贝尔摩德</text>\r\n",
       "</g>\r\n",
       "<!-- 2&#45;&gt;3 -->\r\n",
       "<g id=\"edge3\" class=\"edge\"><title>2&#45;&gt;3</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M138.867,-341.907C126.87,-330.211 113.79,-317.457 101.813,-305.78\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"104.121,-303.142 94.5174,-298.667 99.234,-308.154 104.121,-303.142\"/>\r\n",
       "</g>\r\n",
       "<!-- 4 -->\r\n",
       "<g id=\"node5\" class=\"node\"><title>4</title>\r\n",
       "<path fill=\"#39e581\" stroke=\"black\" d=\"M240,-298.5C240,-298.5 151,-298.5 151,-298.5 145,-298.5 139,-292.5 139,-286.5 139,-286.5 139,-242.5 139,-242.5 139,-236.5 145,-230.5 151,-230.5 151,-230.5 240,-230.5 240,-230.5 246,-230.5 252,-236.5 252,-242.5 252,-242.5 252,-286.5 252,-286.5 252,-292.5 246,-298.5 240,-298.5\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"195.5\" y=\"-283.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\r\n",
       "<text text-anchor=\"middle\" x=\"195.5\" y=\"-268.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 3</text>\r\n",
       "<text text-anchor=\"middle\" x=\"195.5\" y=\"-253.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 3, 0]</text>\r\n",
       "<text text-anchor=\"middle\" x=\"195.5\" y=\"-238.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪梨</text>\r\n",
       "</g>\r\n",
       "<!-- 2&#45;&gt;4 -->\r\n",
       "<g id=\"edge4\" class=\"edge\"><title>2&#45;&gt;4</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M185.704,-341.907C187.076,-331.204 188.562,-319.615 189.952,-308.776\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"193.448,-309.031 191.248,-298.667 186.505,-308.141 193.448,-309.031\"/>\r\n",
       "</g>\r\n",
       "<!-- 6 -->\r\n",
       "<g id=\"node7\" class=\"node\"><title>6</title>\r\n",
       "<path fill=\"#8139e5\" stroke=\"black\" d=\"M400,-298.5C400,-298.5 311,-298.5 311,-298.5 305,-298.5 299,-292.5 299,-286.5 299,-286.5 299,-242.5 299,-242.5 299,-236.5 305,-230.5 311,-230.5 311,-230.5 400,-230.5 400,-230.5 406,-230.5 412,-236.5 412,-242.5 412,-242.5 412,-286.5 412,-286.5 412,-292.5 406,-298.5 400,-298.5\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"355.5\" y=\"-283.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\r\n",
       "<text text-anchor=\"middle\" x=\"355.5\" y=\"-268.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 2</text>\r\n",
       "<text text-anchor=\"middle\" x=\"355.5\" y=\"-253.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 2]</text>\r\n",
       "<text text-anchor=\"middle\" x=\"355.5\" y=\"-238.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 贝尔摩德</text>\r\n",
       "</g>\r\n",
       "<!-- 5&#45;&gt;6 -->\r\n",
       "<g id=\"edge6\" class=\"edge\"><title>5&#45;&gt;6</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M364.643,-341.907C363.362,-331.204 361.975,-319.615 360.678,-308.776\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"364.132,-308.18 359.469,-298.667 357.182,-309.012 364.132,-308.18\"/>\r\n",
       "</g>\r\n",
       "<!-- 7 -->\r\n",
       "<g id=\"node8\" class=\"node\"><title>7</title>\r\n",
       "<path fill=\"#42e687\" stroke=\"black\" d=\"M539,-306C539,-306 442,-306 442,-306 436,-306 430,-300 430,-294 430,-294 430,-235 430,-235 430,-229 436,-223 442,-223 442,-223 539,-223 539,-223 545,-223 551,-229 551,-235 551,-235 551,-294 551,-294 551,-300 545,-306 539,-306\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"490.5\" y=\"-290.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">酒精 &lt;= 13.145</text>\r\n",
       "<text text-anchor=\"middle\" x=\"490.5\" y=\"-275.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.254</text>\r\n",
       "<text text-anchor=\"middle\" x=\"490.5\" y=\"-260.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 47</text>\r\n",
       "<text text-anchor=\"middle\" x=\"490.5\" y=\"-245.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [2, 45, 0]</text>\r\n",
       "<text text-anchor=\"middle\" x=\"490.5\" y=\"-230.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪梨</text>\r\n",
       "</g>\r\n",
       "<!-- 5&#45;&gt;7 -->\r\n",
       "<g id=\"edge7\" class=\"edge\"><title>5&#45;&gt;7</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M411.48,-341.907C421.053,-332.651 431.311,-322.732 441.16,-313.209\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"443.838,-315.488 448.594,-306.021 438.972,-310.456 443.838,-315.488\"/>\r\n",
       "</g>\r\n",
       "<!-- 8 -->\r\n",
       "<g id=\"node9\" class=\"node\"><title>8</title>\r\n",
       "<path fill=\"#39e581\" stroke=\"black\" d=\"M471,-179.5C471,-179.5 374,-179.5 374,-179.5 368,-179.5 362,-173.5 362,-167.5 362,-167.5 362,-123.5 362,-123.5 362,-117.5 368,-111.5 374,-111.5 374,-111.5 471,-111.5 471,-111.5 477,-111.5 483,-117.5 483,-123.5 483,-123.5 483,-167.5 483,-167.5 483,-173.5 477,-179.5 471,-179.5\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"422.5\" y=\"-164.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\r\n",
       "<text text-anchor=\"middle\" x=\"422.5\" y=\"-149.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 43</text>\r\n",
       "<text text-anchor=\"middle\" x=\"422.5\" y=\"-134.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 43, 0]</text>\r\n",
       "<text text-anchor=\"middle\" x=\"422.5\" y=\"-119.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪梨</text>\r\n",
       "</g>\r\n",
       "<!-- 7&#45;&gt;8 -->\r\n",
       "<g id=\"edge8\" class=\"edge\"><title>7&#45;&gt;8</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M466.908,-222.907C460.43,-211.763 453.395,-199.658 446.875,-188.439\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"449.828,-186.554 441.777,-179.667 443.775,-190.072 449.828,-186.554\"/>\r\n",
       "</g>\r\n",
       "<!-- 9 -->\r\n",
       "<g id=\"node10\" class=\"node\"><title>9</title>\r\n",
       "<path fill=\"#ffffff\" stroke=\"black\" d=\"M602,-187C602,-187 513,-187 513,-187 507,-187 501,-181 501,-175 501,-175 501,-116 501,-116 501,-110 507,-104 513,-104 513,-104 602,-104 602,-104 608,-104 614,-110 614,-116 614,-116 614,-175 614,-175 614,-181 608,-187 602,-187\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"557.5\" y=\"-171.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">总酚 &lt;= 2.585</text>\r\n",
       "<text text-anchor=\"middle\" x=\"557.5\" y=\"-156.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 1.0</text>\r\n",
       "<text text-anchor=\"middle\" x=\"557.5\" y=\"-141.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 4</text>\r\n",
       "<text text-anchor=\"middle\" x=\"557.5\" y=\"-126.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [2, 2, 0]</text>\r\n",
       "<text text-anchor=\"middle\" x=\"557.5\" y=\"-111.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 琴酒</text>\r\n",
       "</g>\r\n",
       "<!-- 7&#45;&gt;9 -->\r\n",
       "<g id=\"edge9\" class=\"edge\"><title>7&#45;&gt;9</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M513.745,-222.907C518.734,-214.195 524.059,-204.897 529.215,-195.893\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"532.364,-197.438 534.296,-187.021 526.289,-193.959 532.364,-197.438\"/>\r\n",
       "</g>\r\n",
       "<!-- 10 -->\r\n",
       "<g id=\"node11\" class=\"node\"><title>10</title>\r\n",
       "<path fill=\"#39e581\" stroke=\"black\" d=\"M536,-68C536,-68 447,-68 447,-68 441,-68 435,-62 435,-56 435,-56 435,-12 435,-12 435,-6 441,-0 447,-0 447,-0 536,-0 536,-0 542,-0 548,-6 548,-12 548,-12 548,-56 548,-56 548,-62 542,-68 536,-68\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"491.5\" y=\"-52.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\r\n",
       "<text text-anchor=\"middle\" x=\"491.5\" y=\"-37.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 2</text>\r\n",
       "<text text-anchor=\"middle\" x=\"491.5\" y=\"-22.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 2, 0]</text>\r\n",
       "<text text-anchor=\"middle\" x=\"491.5\" y=\"-7.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪梨</text>\r\n",
       "</g>\r\n",
       "<!-- 9&#45;&gt;10 -->\r\n",
       "<g id=\"edge10\" class=\"edge\"><title>9&#45;&gt;10</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M532.924,-103.726C527.646,-94.9703 522.061,-85.7032 516.758,-76.9051\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"519.731,-75.0574 511.571,-68.2996 513.736,-78.671 519.731,-75.0574\"/>\r\n",
       "</g>\r\n",
       "<!-- 11 -->\r\n",
       "<g id=\"node12\" class=\"node\"><title>11</title>\r\n",
       "<path fill=\"#e58139\" stroke=\"black\" d=\"M667,-68C667,-68 578,-68 578,-68 572,-68 566,-62 566,-56 566,-56 566,-12 566,-12 566,-6 572,-0 578,-0 578,-0 667,-0 667,-0 673,-0 679,-6 679,-12 679,-12 679,-56 679,-56 679,-62 673,-68 667,-68\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"622.5\" y=\"-52.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\r\n",
       "<text text-anchor=\"middle\" x=\"622.5\" y=\"-37.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 2</text>\r\n",
       "<text text-anchor=\"middle\" x=\"622.5\" y=\"-22.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [2, 0, 0]</text>\r\n",
       "<text text-anchor=\"middle\" x=\"622.5\" y=\"-7.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 琴酒</text>\r\n",
       "</g>\r\n",
       "<!-- 9&#45;&gt;11 -->\r\n",
       "<g id=\"edge11\" class=\"edge\"><title>9&#45;&gt;11</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M581.704,-103.726C586.901,-94.9703 592.402,-85.7032 597.625,-76.9051\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"600.638,-78.6853 602.733,-68.2996 594.619,-75.1121 600.638,-78.6853\"/>\r\n",
       "</g>\r\n",
       "<!-- 13 -->\r\n",
       "<g id=\"node14\" class=\"node\"><title>13</title>\r\n",
       "<path fill=\"#8139e5\" stroke=\"black\" d=\"M603,-417.5C603,-417.5 514,-417.5 514,-417.5 508,-417.5 502,-411.5 502,-405.5 502,-405.5 502,-361.5 502,-361.5 502,-355.5 508,-349.5 514,-349.5 514,-349.5 603,-349.5 603,-349.5 609,-349.5 615,-355.5 615,-361.5 615,-361.5 615,-405.5 615,-405.5 615,-411.5 609,-417.5 603,-417.5\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"558.5\" y=\"-402.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\r\n",
       "<text text-anchor=\"middle\" x=\"558.5\" y=\"-387.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 4</text>\r\n",
       "<text text-anchor=\"middle\" x=\"558.5\" y=\"-372.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 4]</text>\r\n",
       "<text text-anchor=\"middle\" x=\"558.5\" y=\"-357.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 贝尔摩德</text>\r\n",
       "</g>\r\n",
       "<!-- 12&#45;&gt;13 -->\r\n",
       "<g id=\"edge13\" class=\"edge\"><title>12&#45;&gt;13</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M559.806,-460.907C559.623,-450.204 559.425,-438.615 559.24,-427.776\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"562.737,-427.606 559.067,-417.667 555.738,-427.725 562.737,-427.606\"/>\r\n",
       "</g>\r\n",
       "<!-- 14 -->\r\n",
       "<g id=\"node15\" class=\"node\"><title>14</title>\r\n",
       "<path fill=\"#e68742\" stroke=\"black\" d=\"M742,-425C742,-425 645,-425 645,-425 639,-425 633,-419 633,-413 633,-413 633,-354 633,-354 633,-348 639,-342 645,-342 645,-342 742,-342 742,-342 748,-342 754,-348 754,-354 754,-354 754,-413 754,-413 754,-419 748,-425 742,-425\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"693.5\" y=\"-409.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">镁 &lt;= 135.5</text>\r\n",
       "<text text-anchor=\"middle\" x=\"693.5\" y=\"-394.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.267</text>\r\n",
       "<text text-anchor=\"middle\" x=\"693.5\" y=\"-379.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 44</text>\r\n",
       "<text text-anchor=\"middle\" x=\"693.5\" y=\"-364.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [42, 2, 0]</text>\r\n",
       "<text text-anchor=\"middle\" x=\"693.5\" y=\"-349.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 琴酒</text>\r\n",
       "</g>\r\n",
       "<!-- 12&#45;&gt;14 -->\r\n",
       "<g id=\"edge14\" class=\"edge\"><title>12&#45;&gt;14</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M606.644,-460.907C617.372,-451.469 628.884,-441.343 639.903,-431.649\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"642.241,-434.254 647.438,-425.021 637.618,-428.998 642.241,-434.254\"/>\r\n",
       "</g>\r\n",
       "<!-- 15 -->\r\n",
       "<g id=\"node16\" class=\"node\"><title>15</title>\r\n",
       "<path fill=\"#e58139\" stroke=\"black\" d=\"M710,-298.5C710,-298.5 613,-298.5 613,-298.5 607,-298.5 601,-292.5 601,-286.5 601,-286.5 601,-242.5 601,-242.5 601,-236.5 607,-230.5 613,-230.5 613,-230.5 710,-230.5 710,-230.5 716,-230.5 722,-236.5 722,-242.5 722,-242.5 722,-286.5 722,-286.5 722,-292.5 716,-298.5 710,-298.5\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"661.5\" y=\"-283.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\r\n",
       "<text text-anchor=\"middle\" x=\"661.5\" y=\"-268.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 42</text>\r\n",
       "<text text-anchor=\"middle\" x=\"661.5\" y=\"-253.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [42, 0, 0]</text>\r\n",
       "<text text-anchor=\"middle\" x=\"661.5\" y=\"-238.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 琴酒</text>\r\n",
       "</g>\r\n",
       "<!-- 14&#45;&gt;15 -->\r\n",
       "<g id=\"edge15\" class=\"edge\"><title>14&#45;&gt;15</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M682.398,-341.907C679.44,-331.094 676.235,-319.376 673.245,-308.441\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"676.586,-307.389 670.571,-298.667 669.834,-309.236 676.586,-307.389\"/>\r\n",
       "</g>\r\n",
       "<!-- 16 -->\r\n",
       "<g id=\"node17\" class=\"node\"><title>16</title>\r\n",
       "<path fill=\"#39e581\" stroke=\"black\" d=\"M841,-298.5C841,-298.5 752,-298.5 752,-298.5 746,-298.5 740,-292.5 740,-286.5 740,-286.5 740,-242.5 740,-242.5 740,-236.5 746,-230.5 752,-230.5 752,-230.5 841,-230.5 841,-230.5 847,-230.5 853,-236.5 853,-242.5 853,-242.5 853,-286.5 853,-286.5 853,-292.5 847,-298.5 841,-298.5\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"796.5\" y=\"-283.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\r\n",
       "<text text-anchor=\"middle\" x=\"796.5\" y=\"-268.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 2</text>\r\n",
       "<text text-anchor=\"middle\" x=\"796.5\" y=\"-253.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 2, 0]</text>\r\n",
       "<text text-anchor=\"middle\" x=\"796.5\" y=\"-238.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪梨</text>\r\n",
       "</g>\r\n",
       "<!-- 14&#45;&gt;16 -->\r\n",
       "<g id=\"edge16\" class=\"edge\"><title>14&#45;&gt;16</title>\r\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M729.235,-341.907C739.338,-330.432 750.336,-317.938 760.457,-306.442\"/>\r\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"763.321,-308.486 767.302,-298.667 758.067,-303.86 763.321,-308.486\"/>\r\n",
       "</g>\r\n",
       "</g>\r\n",
       "</svg>\r\n"
      ],
      "text/plain": [
       "<graphviz.files.Source at 0xb638808>"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import graphviz\n",
    "\n",
    "# 特征名称\n",
    "feature_name = ['酒精', '苹果酸', '灰', '灰的碱性', '镁', '总酚', '类黄酮', '非黄烷类酚类', '花青素', '颜色强度', '色调', 'od280/od315稀释葡萄酒', '脯氨酸']\n",
    "\n",
    "dot_data = tree.export_graphviz(clf, # 训练模型\n",
    "                                feature_names=feature_name, # 特征名称\n",
    "                                class_names = ['琴酒', '雪梨', '贝尔摩德'], \n",
    "                                filled=True,\n",
    "                                rounded=True\n",
    "                               )\n",
    "graph = graphviz.Source(dot_data)\n",
    "graph"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
